package servlet;


import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.util.List;

/*request 作用域
* 通过该对象可以在一个请求中传递数据：作用范围：在一次请求中生效，即服务器跳转有效。（请求转发跳转时有效）
* //设置域对象内容
* //获取域对象内容
* //删除域对象内容*/
@WebServlet("/s05")
public class servlet05 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("servlet05");
        //设置域对象内容
        request.setAttribute("name","admin");
        request.setAttribute("age",18);
        List<String> list = List.of("aaa","bbb");
        request.setAttribute("list",list);

        //请求跳转到s06
        request.getRequestDispatcher("s06").forward(request, response);



    }
}
